package com.na.onlineservey.answeringtype


import com.docu.common.Action
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import com.na.onlineservey.AnsweringTypeService
import com.na.onlineservey.AnsweringType

@Component("createAnsweringTypeAction")
class CreateAnsweringTypeAction extends Action {

  @Autowired
  AnsweringTypeService answeringTypeInstanceService

  public Object preCondition(Object params, Object object) {
    try {
      AnsweringType answeringTypeInstance = (AnsweringType) object
      if (!answeringTypeInstance.validate()) {
        return null
      }
      return answeringTypeInstance
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object execute(Object params, Object object) {
    try {
      return answeringTypeInstanceService.create(object)
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object postCondition(Object params, Object object) {
    return null
  }
}